#!/bin/bash
#20210813
t=$(date +%m%d)
lt=$(date +%Y%m%d%H%M)
a="初始化redis"
b="开启对时权限"
c="关闭防火墙"
d="设置串口权限"
e="关闭selinux"
f="程序启动配置"
g="防火墙规则配置"
m="mysql"
abcd="执行第1至第4项内容"
z="完成"

#o="系统查询"
temp="/work/temp"
bak_file="bakfile"
logn="logname"

#echo "`pwd`"
function f_select() {
	PS3=-'请输入对应的数字选择要执行的操作！'
	select slt in ${a} ${b} ${c} ${d} ${abcd} ${e} ${f} ${g} ${m} ${z}; do
		case ${slt} in
		"${a}")
			logn=${a}
			cd ./Redis_init
			./redis.sh "p70"
			cd ..
			f_log
			break
			;;
		"${b}")
			logn=${b}
			./date.sh
			f_log
			break
			;;
		"${c}")
			logn=${c}
			cd ./firewall
			./firewall.sh stop
			cd ..
			f_log
			break
			;;
		"${d}")
			logn=${d}
			./serial.sh
			f_log
			break
			;;
		"${abcd}")
			logn=${abcd}
			cd ./Redis_init
			./redis.sh "p70"
			cd ..
			./date.sh
			cd ./firewall
			./firewall.sh stop
			cd ..
			./serial.sh
			f_log
			break
			;;
		"${f}")
			logn=${f}
			./act-select.sh
			f_log
			break
			;;
		"${g}")
			logn=${g}
			./fw-select.sh
			f_log
			break
			;;
		"${e}")
	        logn=${e}
	        ./close-selinux.sh
	        f_log
			break
			;;
	  "${m}")
			logn=${e}
			cd install-mysql
			./install.sh
			cd ..
			f_log
			break
			;;
		"${z}")
			echo 'bay,bay!!'
			exit
			;;
		*)
			echo "输入错误，请重新选择！"
			break
			;;
		esac
	done
	f_select
}
function f_log() {
	if [ ! -d ${PWD}/log ]; then
		mkdir ${PWD}/log
		chmod 755 -R ${PWD}/log
	fi
	if [ ! -e ${PWD}/log/bak.log ]; then
		touch ${PWD}/log/bak.log
	fi
	#echo  "[" ` date '+%F %T %3N'`"]:">> ${PWD}/log/bak.log ##时间
	echo ${PWD}
	echo "["$(date '+%F %T %3N')"]:""选择了"${slt} >>${PWD}/log/bak.log
	echo "["$(date '+%F %T %3N')"]:""执行"${logn} >>${PWD}/log/bak.log
}
f_select
